<?php
	
	$message = $vars['message'];
	$offset = $vars['offset'];
	$user = $vars['message_owner'];
	
	$smiley_url = $vars['url'] . "action/elggchat/get_smiley?_" . time() . "&smiley=";
	
	$randomint = time();
	$smileys = array(
		":(|)"=>"<img src='" . $smiley_url . "animated_smileys/monkey.gif'>",
		"=D"=>"<img src='" . $smiley_url . "animated_smileys/smile.gif'>",
		":)"=>"<img src='" . $smiley_url . "animated_smileys/smile.gif'>",
		";)"=>"<img src='" . $smiley_url . "animated_smileys/wink.gif'>",
		":("=>"<img src='" . $smiley_url . "animated_smileys/frown.gif'>",
		":D"=>"<img src='" . $smiley_url . "animated_smileys/grin.gif'>",
		"x-("=>"<img src='" . $smiley_url . "animated_smileys/angry.gif'>",
		"B-)"=>"<img src='" . $smiley_url . "animated_smileys/cool.gif'>",
		":'("=>"<img src='" . $smiley_url . "animated_smileys/cry.gif'>",
		"\m/"=>"<img src='" . $smiley_url . "animated_smileys/rockout.gif'>",
		":-o"=>"<img src='" . $smiley_url . "animated_smileys/shocked.gif'>",
		":-/"=>"<img src='" . $smiley_url . "animated_smileys/slant.gif'>",
		":-|"=>"<img src='" . $smiley_url . "animated_smileys/straightface.gif'>",
		":P"=>"<img src='" . $smiley_url . "animated_smileys/tongue.gif'>",
		":-D"=>"<img src='" . $smiley_url . "animated_smileys/nose_grin.gif'>",
		";-)"=>"<img src='" . $smiley_url . "animated_smileys/wink_nose.gif'>",
		";^)"=>"<img src='" . $smiley_url . "animated_smileys/wink_big_nose.gif'>",
		
		);
	
	if($message->access_id != ACCESS_PRIVATE || $user->guid == get_loggedin_userid()){
		if($message->name == "elggchat_message"){
			echo "<div name='message' id='" .  $offset . "' class='messageWrapper'>";
			
			echo "<table ><tr><td rowspan='3'>";
			echo "<a href='" . $user->getURL() . "' target='_blank'><img class='messageIcon' alt='" . $user->name . "' src='". $user->getIcon('tiny') . "'></a>";
			echo "<td><td class='messageName'>" . $user->name . "</td></tr>";
			
			echo "<tr><td></td><td>";

			echo str_ireplace(array_keys($smileys), array_values($smileys), $message->value);

			echo "</td></tr></table>";
			echo "</div>";
		} elseif($message->name == "elggchat_system_message") {
			echo "<div name='message' id='" .  $offset . "' class='systemMessageWrapper'>";
			echo $message->value;
			echo "</div>";
		}
	}
?>